<template>
	<view>
		<u-navbar>
			<view class="u-nav-slot" slot="left" :style="{width:`calc(750rpx - 40rpx - ${paddingright})`}">
				<image class="back_icon" @click="back" src="/static/img/back.png" mode=""></image>
				<view class="left">
					<u-search placeholder="搜索你需要购买的商品" :disabled='true' height="73rpx" :focus='false' v-model="keyword"
						:showAction='false' @click='clickto("/pages/searchpage/searchpage")'></u-search>
				</view>
			</view>
		</u-navbar>
		<view class="con" :style="{paddingTop:marginTop+'px'}">
			<view class="smartinfo flex">
				<image class="smasrtpic" :src="baseurl+info.image" mode=""></image>
				<view class="info">
					<view class="name">
						{{info.name}}
					</view>
					<view class="num">
						商品数量{{count}}件
					</view>
					<view class="jj">
						店铺简介内容:{{info.intro}}
					</view>
				</view>
				<image class="moreicon" src="/static/img/home/more.png" mode=""></image>
			</view>
			<view class="">
				<u-tabs @click="tabsChange" itemStyle='height:80rpx;padding:0 29rpx;' :list="list1" lineHeight='12rpx'
					lineWidth='32rpx' lineColor='#FF7428'
					activeStyle="color:#232323;font-size:41.67rpx;font-weight: bold;"
					inactiveStyle="color:#707070;fontSize:31.95rpx"></u-tabs>
			</view>
			<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="scrolltolower">
				<view class="content">
					<proitem v-for="(item,index) in prolist" :key="index" :pro="item" :tab="item.t"></proitem>
				</view>
				<!-- <u-loadmore :status="status" @loadmore="scrolltolower" /> -->
			</scroll-view>
		</view>

	</view>
</template>

<script>
	import {
		homeData
	} from '@/api/home.js'
	import {
		getProductByCateGory,getStore
	} from '@/api/product.js'
	
	export default {
		data() {
			return {
				paddingright: 0,
				marginTop: 0,
				keyword: '',
				list1: [],
				prolist: [],
				info:{},
				baseurl:"",
				page:1,
				last_page:1,
				status:'loadmore',
				category_id:null,
				listKey:null,
				count:0,
				id:null
			};
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			clickto(url) {
				uni.$u.route(url)
			},
			tabsChange(item) {
				if (this.listKey == item.id) return false;
				// console..onLoad
				this.category_id = item.id;
				// console.log(this.category_id)
				this.getdatalist()
			},
			// 获取店铺信息
			getdata(id){
				let page=this.page
				getStore({id,page}).then(res=>{
					this.info=res.data.data.store
					this.list1=res.data.data.category
					this.category_id=this.list1[0].id
					this.count=res.data.data.count
					this.getdatalist()
				})
			},
			getdatalist(id){
				getProductByCateGory({category_id:this.category_id,store:this.id}).then(res=>{
					this.prolist=res.data.data
					this.prolist.map(t=>{
						t.img=this.$BASE_URL+t.images.split(',')[0]
						switch (t.type){
							case 1:
								t.t='no'
								break;
							case 2:
								t.t='tz'
								break;
							case 3:
								t.t='jf'
								break;
						}
					})
				})
			},
		},
		onLoad(option) {
			this.baseurl=this.$BASE_URL
			this.paddingright = uni.getStorageSync('paddingright')
			this.marginTop = 53 + uni.getStorageSync('statusBarHeight')
			this.id=option.user_id
			this.getdata(option.user_id)
		}
	}
</script>

<style lang="less">
	.u-nav-slot {
		display: flex;
		align-items: center;
		width: calc(750rpx - 40rpx);

		.back_icon {
			width: 18rpx;
			height: 32rpx;
			margin-right: 26rpx;
		}

		.left {
			width: 100%;
		}
	}

	.smartinfo {
		padding: 30rpx;
		justify-content: space-between;
		border-bottom: #F4F5F6 1px solid;

		.smasrtpic {
			width: 135rpx;
			height: 135rpx;
			border-radius: 10rpx;
		}

		.moreicon {
			width: 12rpx;
			height: 22rpx;
		}

		.info {
			width: 508rpx;
			height: 135rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.name {
				color: #232323;
				font-size: 30rpx;
				font-weight: bold;
			}

			.num {
				padding: 0 10rpx;
				line-height: 41rpx;
				background: rgba(255, 116, 40, 0.15);
				border-radius: 8rpx;
				font-size: 21rpx;
				color: #FF7428;
				width: fit-content;
			}

			.jj {
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: nowrap;
				color: #707070;
				font-size: 24rpx;
			}
		}
	}

	.content {
		background-color: #fff;
		padding: 26rpx 20rpx 0;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	.scroll-view {
		height: calc(100vh - 44px - var(--status-bar-height) - 135rpx - 60rpx  - 80rpx - 26rpx);
	}
</style>
